#!/bin/bash # It is recommended to test the script on a local machine for its purpose and effects. # ManageEngine Endpoint Central will not be responsible for any # damage/loss to the data/setup based on the behavior of the script. # Description - Script to look for machines that have not been restarted in 5 number of days and displays a reboot alert # Configuration Type - COMPUTER # Name: checkUpTime.sh # Note: Pls change the maxDays according to your requirement days=`uptime | awk '{ print $4 }' | sed 's/,//g'` # grabs the word "days" if it is there num=`uptime | awk '{ print $3 }'` # grabs the number of hours or days in the uptime command maxDays=5 if [ $num -gt $maxDays ]; then osascript -e 'display alert "Reboot Alert" message "You havent rebooted the machine for more than '$num' days Please reboot your machines"' fi echo $num $days